import React,{Component} from 'react'
import register from './Register.module.css'
import { Input } from 'antd';
import { Button } from 'antd';
import {NavLink} from 'react-router-dom'
import*as api from '../until/login.js'
export default class Registr extends Component{
	reg(){
		api.register({
			userName: document.querySelector('#ipt').value,
			password: document.querySelector('#ipt1').value
		}).then((res) => {
			if(res.data.code==='success'){
				alert('注册成功')
				this.props.history.push('/login')
			}else{
				alert('用户名已存在')
			}
			
		})
	}
	render(){
		return(
			<div className={register.body}>
				<div className={register.box}>
					<p>新用户注册</p>
					<Input placeholder="请输入账号" id='ipt'/>
					<Input placeholder="请输入密码" type="password" id='ipt1'/>
					<Input placeholder="请确认密码" type="password"/>
					<Button type="danger" onClick={()=>this.reg()} className={register.button}>注册</Button>
					 <NavLink to='/login' className={register.span}>返回登录</NavLink>
				</div>
			</div>
		)
	}
	
}